package com.chushouya.common.applet;

import com.alibaba.fastjson.JSONObject;

import java.util.LinkedHashMap;
import java.util.Map;

final class MessageUtil {

    /**
     * 构建订阅消息参数字符串
     *
     * @param data 消息参数，参数保证有序
     */
    static String buildMessageData(LinkedHashMap<String, String> data) {
        JSONObject result = new JSONObject(data.size(), true);
        for (Map.Entry<String, String> entry : data.entrySet()) {
            JSONObject value = new JSONObject(true);
            value.put("value", entry.getValue());
            result.put(entry.getKey(), value);
        }
        return result.toString();
    }

}
